set more off

use dataset, clear

*** recoding for log scale ***

forvalues i = 1(1)1000 {
	local log`i' = log(`i'+1)
}
local loghalf = log(.5 + 1)

*** recoding ***

replace pctblack = exp(pctblack) - 1
gen underrepresentation = pctblack - pctblackgov
replace underrep = 0 if underrep < 0
replace underrep = . if mi(pctblackgov)
replace underrep = log(under + 1)

*** graph ***

#delimit;

gr tw 
	(sc lfinesandforfeitspcp underrep, msize(tiny) col(gs10))
	(lfit lfinesandforfeitspcp underrep, col(black) lwid(thick) lpat(dash))
	(lowess lfinesandforfeitspcp underrep, col(black))
	,
		legend(off)
		ylab(
			0 "0"
 			`log1' "1"
			`log2' "2"
			`log5' "5"
			`log10' "10"
			`log20' "20"
			`log35' "35"
			`log100' "100"
			`log500' "500"		
			,
			angle(horiz)
		)
		xlab(
			0 "0"
			`log1' "1"
			`log5' "5"
			`log10' "10"
			`log25' "25"
			`log50' "50"
			`log100' "100"
			
		)	
		plotregion(style(none))
		xtitle("Black underrepresentation")	
		ytitle("Fines revenue per capita")
		;
		
#delimit cr

gr export "figureA7.eps", replace
shell epstopdf figureA7.eps
